/**
 * 
 */
package org.vsg.common.pagination.apps;

import java.util.Properties;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Bill vison
 *
 */
public class HttpPaginationApplicationContextFactory {

	private final static Logger logger = LoggerFactory.getLogger(HttpPaginationApplicationContextFactory.class);	
	
	public static final HttpPaginationApplicationContext getPaginationContext(HttpServletRequest request) throws PaginationApplicationContextException{
		
		// --- defined value ---
		Properties props = new Properties();
	
		return getPaginationContext(request , props);
	}
	
	public static final HttpPaginationApplicationContext getPaginationContext(HttpServletRequest request , Properties props) throws PaginationApplicationContextException{
		
		// --- check the request object is null or not ---
		if (request == null) {
			throw new PaginationApplicationContextException("There aren't to be set the HttpServletRuqest Object.");
		}
		
		// --- create pagination application context ---
		HttpPaginationApplicationContext context = new HttpPaginationApplicationContext();
		context.setRequest( request );
		context.setConfiguration(props);
		
		context.initializeConfiguration();
				
		return context;
	}

}
